package tech.horgee.executor;

import org.slf4j.MDC;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import tech.horgee.log.utils.TraceIdUtil;

import java.util.concurrent.Future;

public class MyThreadPool extends ThreadPoolTaskExecutor {
    @Override
    public void execute(Runnable task) {
        super.execute(TraceIdUtil.wrap(task, MDC.getCopyOfContextMap()));
    }

    @Override
    public Future<?> submit(Runnable task) {
        return super.submit(TraceIdUtil.wrap(task, MDC.getCopyOfContextMap()));
    }
}
